<?php

class Kd_Aop_Listener_Trace {

    public static function traceDb($position, $object, $method, $argyments){
        if($position == Kd_Aop_Observer::$INVOKE_AFTER){
            $traceDirectory = Kd_Config::getTmpPath().'trace';
            if(!is_dir($traceDirectory)){
                mkdir($traceDirectory, '0755', TRUE);
            }
            $content = "-------------------\n{$object->getBoundSql()}\n----------------------\n";
            file_put_contents($traceDirectory.DIRECTORY_SEPARATOR.'dbtrace.log', $content, FILE_APPEND);
        }
    }
}